#pragma once
#include"RBtree.h"
namespace zcg
{	
	template<class K,class V>
	class mymap
	{
	public:
		struct keyofmap
		{
			const K& operator()(const pair<K, V>& data)
			{
				return data.first;
			}
		};

		typedef typename RBTree<K, pair<K, V>, keyofmap>::iterator iterator;
		pair<iterator, bool> insert(const pair<K,V>& kv)
		{
			return _t.Insert(kv);
		}
		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		void InOrder()
		{
			_t.InOreder();
		}
		V& operator[](const K& key)
		{
			auto ret =insert(make_pair(key,V()));
			return ret.first->second;
		}
	private:
		RBTree<K, pair<K, V>, keyofmap> _t;
	};
}